#ifndef BMEMORY_H
#define BMEMORY_H

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
 * This file is part of Suneido - The Integrated Application Platform
 * see: http://www.suneido.com for more information.
 * 
 * Copyright (c) 2000 Suneido Software Corp. 
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation - version 2. 
 *
 * This program is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.  See the GNU General Public License in the file COPYING
 * for more details. 
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the Free
 * Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <stdlib.h>

class Ostream;

const int GCSIZES = 128;

struct GcStats
	{
	int minsize;
	int free_count;
	int free_size;
	int ptr_count;
	int ptr_size;
	int nonptr_count;
	int nonptr_size;
	};

Ostream& operator<<(Ostream&, GcStats*);

void* gc_alloc(int n, bool has_pointers = true);
void* gc_realloc(void* p, size_t n);
int gc_size(void* p);
void garbage_collect();
void finalize(void* ob);
void removefinal(void* ob);
void* nextfinal();
int gc_arenasize();
GcStats* gc_stats();
bool gc_inheap(void* p);
bool gc_has_pointers(void* p);

#if 0
#ifdef _MSC_VER
#pragma warning(4 : 4291)
	
void* operator new(size_t n);
void* operator new[](size_t n);
#endif
	
struct NoPtrs { };
extern NoPtrs noptrs;
	
void* operator new(size_t n, NoPtrs);
void* operator new[](size_t n, NoPtrs);
#endif

void push_static_roots(void (*push)(void*, void*));

#endif
